﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
using System.Timers;
using System.IO;

namespace Friesland_Campina_UpdateStock
{
    class Program
    {
        
        public static void Main(string[] args)
        {
            string logText = "";
            string path = AppDomain.CurrentDomain.BaseDirectory+ "\\log.txt";
            StreamWriter file = File.AppendText(path);
            try
            {
                Updating obj = new Updating();
                Console.WriteLine("updating ...");
                int result = obj.update(DateTime.Now.Date);
                logText = String.Format("update susscess {0} rows at {1}", result, DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));
            }
            catch (Exception ex)
            {
                logText = String.Format("update fail throw exception {0} at {1}", '"' + ex.Message + '"', DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));
            }
            finally
            {
                Console.WriteLine(logText);
                file.WriteLine(logText);
                file.Close();
            }
            Environment.Exit(0);
        }
    }
}
